<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
$conn = @mysql_connect("localhost","root","root");
if (!$conn){
    die("Could not connect：" . mysql_error());
}

mysql_select_db("devildark", $conn);
mysql_query("set names 'UTF-8'"); 
 
$deviceid_query =  mysql_query("SELECT DISTINCT deviceid FROM devildark where JailBreak = '0'");

while($deviceid = mysql_fetch_array($deviceid_query))
{
     //进入游戏次数
    $playNum_query = mysql_query("SELECT count(1) FROM devildark where deviceid = '$deviceid[deviceid]'");

    $playNum = mysql_fetch_array($playNum_query);

     //总游戏时间
    $TotalGameTime_query = mysql_query("SELECT GamingTime FROM devildark_last where deviceid = '$deviceid[deviceid]'");
    $TotalGameTime = mysql_fetch_array($TotalGameTime_query);

    //最后停留等级
    $level_query = mysql_query("SELECT CurrentPlayerLevel FROM devildark_last where deviceid = '$deviceid[deviceid]'");
    $level = mysql_fetch_array($level_query);

    var_dump($playNum[0]);
 
$sql = "UPDATE report_nojailbreak_total SET playNum= '$playNum[0]' WHERE deviceid= '$deviceid[deviceid]'";
$sql2 = "UPDATE report_nojailbreak_total SET TotalGameTime= '$TotalGameTime[0]' WHERE deviceid= '$deviceid[deviceid]'";
//$sql3 = "UPDATE report_nojailbreak_total SET Survival= '$Survival[0]' WHERE deviceid= '$deviceid[deviceid]'";
$sql4 = "UPDATE report_nojailbreak_total SET level= '$level[0]' WHERE deviceid= '$deviceid[deviceid]'";

if(mysql_query($sql,$conn)){
    echo "1 update is ok!";
} else {
    echo "failed：".mysql_error();
}
if(mysql_query($sql2,$conn)){
    echo "2 update is ok!";
} else {
    echo "failed：".mysql_error();
}/*
if(mysql_query($sql3,$conn)){
    echo "3 update is ok!";
} else {
    echo "failed：".mysql_error();
}*/
if(mysql_query($sql4,$conn)){
    echo "4 update is ok!";
} else {
    echo "failed：".mysql_error();
}

}
?>
